#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000 + 5;
int v[MAXN];
int dp[MAXN][3];
int main()
{
#ifdef LOCAL
    freopen("ADV-302.in", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    dp[1][0] = v[1];
    for(int i = 2; i <=n; ++i)
    {
        dp[i][0] = v[i] + min(dp[i - 1][1], min(dp[i - 1][2], dp[i - 1][0]));
        dp[i][1] = dp[i - 1][0];
        dp[i][2] = dp[i - 2][0];
    }
    int ans = min(dp[n][1], min(dp[n][2], dp[n][0]));
    cout << ans << endl;
    return 0;
}